package top.fyukina.fymil.internal.cmds;

import org.dom4j.Element;
import top.fyukina.fymil.Util;
import top.fyukina.fymil.elements.Environment;

public class Input implements Command {
    @Override
    public String registerName() {
        return "input";
    }
    @Override
    public void run(Element tag, Environment env) {
        String c = "";
        if (Util.scanner.hasNext()) {
            c = Util.scanner.nextLine();
        }
        Element elFor = tag.element("for");
        if (elFor != null) {
            String id = elFor.attributeValue("id");
            if (id != null) {
                env.var().saveVar(id, c);
            }
        }
    }
}